﻿using Inaction.Host;
using Inaction.ServiceProxy;
using System;
using System.Security.Principal;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

namespace Inaction.Service.Hosts
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebService : System.Web.Services.WebService, Inaction.Host.IHost
    {
        #region 构造

        public WebService()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
        }

        void UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = (System.Exception)(e.ExceptionObject);
            Inaction.Util.Loger.WriteLog(exception);
        }
        #endregion

        #region IHost 成员
        [WebMethod(Description = "登陆")]
        public Response Login(Request request)
        {
            return HostHelper.Login(request);
        }

        [WebMethod(Description = "查询数据")]
        public Response Query(Request request)
        {
            return HostHelper.Query(request);
        }

        [WebMethod(Description = "保存数据")]
        public Response Save(Request request)
        {
            return HostHelper.Save(request);
        }

        [WebMethod(Description = "执行命令")]
        public Response Excute(Request request)
        {
            return HostHelper.Excute(request);
        }

        [WebMethod(Description = "执行远程方法")]
        public Response Invoke(Request request)
        {
            return HostHelper.Invoke(request);
        }
        #endregion
    }
}